package olga.gorbatiuk.perdep.logger.record;

import olga.gorbatiuk.perdep.logger.exceptions.MyIllegalArgumentException;

public enum Importance {

    ONE(1, ".    "), TWO(2, "!    "), THREE(3, "!!!  "), FOUR(4, "!!!!!");

    private final int intValue;
    private final String stringValue;

    Importance(int intValue, String stringValue) {
        this.intValue = intValue;
        this.stringValue = stringValue;
    }

    public int getIntValue() {
        return intValue;
    }

    public String getStringValue() {
        return stringValue;
    }

    public static Importance fromString(String stringValue) throws MyIllegalArgumentException {
        if ((stringValue == null) || (stringValue.trim().isEmpty())) {
            throw new MyIllegalArgumentException(
                    "Value shouldn't be null or empty");
        }

        switch (stringValue) {
            case ".":
                return ONE;
            case "!":
                return TWO;
            case "!!!":
                return THREE;
            case "!!!!!":
                return FOUR;

            default:
                throw new MyIllegalArgumentException("No such enum value");
        }
    }
}
